package com.fjnldx.mes.domain.domainRes;

import lombok.Data;
import org.springframework.stereotype.Component;

@Component
@Data
public class Result<T> {
    private Integer code;
    private String msg;
    private T data;

    public static<T> Result<T> success(T data) {
        return new Result<T>(1, "操作成功", data);
    }
    public static<T> Result<T> error(T data) {
        return new Result<T>(-1, "操作失败", data);
    }
    public static<T> Result<T> success() {
        return new Result<T>(1, "操作成功", null);
    }
    public static<T> Result<T> error() {
        return new Result<T>(-1, "操作失败", null);
    }
    public static<T> Result<T> success(String msg,T data) {
        return new Result<T>(1, msg, data);
    }


    public Result() {
    }

    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
}
